package com.sky.controller.admin;

import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.vo.DishVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/dish")
public class DishController {
    @Autowired
    private DishService dishService;


    /**
     * 分页查询
     * @param dishPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result pageDish(DishPageQueryDTO dishPageQueryDTO){
        return dishService.pageDish(dishPageQueryDTO);
    }


    /**
     * 新增菜品
     * @param dishDTO
     * @return
     */
    @PostMapping()
    public Result addFish(@RequestBody DishDTO dishDTO){
        return dishService.addFish(dishDTO);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @DeleteMapping
    public Result deleteDish(@RequestParam List<Long> ids) {
        return dishService.deleteDish(ids);
    }

    /**
     *  改变菜品状态
     * @return
     */
    @PostMapping("/status/{status}")
    public Result changeDishStatus( @PathVariable Integer status , Long id){
        return dishService.changeDishStatus(status, id);
    }


    /**
     * 根据分类id查询菜品
     * @param categoryId
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("根据分类id查询菜品")
    public Result<List<Dish>> list(Long categoryId){
        List<Dish> list = dishService.list(categoryId);
        return Result.success(list);
    }
}
